package com.top10.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.top10.common.DatabaseConst;
import com.top10.entity.Consignee;
import com.top10.mapper.AdminMapper;
import com.top10.mapper.ConsigneeMapper;
import com.top10.service.ConsigneeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConsigneeServiceImpl implements ConsigneeService {
	@Autowired
	private AdminMapper adminMapper;
	@Autowired
	private ConsigneeMapper consigneeMapper;

	@Override
	public String getUuid(String account)throws Exception{
		return adminMapper.selecttwo(account);
	}
	@Override
	public List<Consignee> getAll(String user_uuid)throws Exception{
		return consigneeMapper.selectList(new EntityWrapper<Consignee>().eq("user_uuid",user_uuid).eq("isdeleted",DatabaseConst.IS_DELETED_NO));
	}
	@Override
	public Integer updateConsignee(Consignee consignee)throws Exception{
		return consigneeMapper.update(consignee,new EntityWrapper<Consignee>().eq("id",consignee.getId()));
	}
	@Override
	public Integer deletedConsignee(Integer id)throws Exception{
		return consigneeMapper.updateOne(id);
	}
	@Override
	public Integer defaultConsignee(Integer id)throws Exception{
		return  consigneeMapper.updateTwo(id);
	}
	@Override
	public  Integer addConsignee(Consignee consignee)throws Exception{
		return  consigneeMapper.insert(consignee);
	}

	@Override
	public Consignee selectConsignee(String user_uuid)throws Exception{
		return consigneeMapper.selectConsignee(user_uuid);
	}
	@Override
	public Consignee selectConsigneeone(String uuid)throws Exception{
		return consigneeMapper.selectConsigneeone(uuid);
	}
}
